﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
    public class DynamicDefinitionInfo
    {
        public FieldCol Fields;
        public class Field
        {
            public int Index { get; set; }
            public string Name { get; set; }
            public string Value { get; set; }
            public Type Type { get; set; }
            public int Count { get; set; }
            public int StartClientBuild { get; set; }
            public int EndClientBuild { get; set; }
            public string Description { get; set; }
            public string SQLFieldName { get; set; }
            public FieldCol SubFields { get; set; }

        }

        public class FieldCol : List<Field>
        {
            public Field AddField(string pName, Type pType, int pCount, int pStartClientBuild, int pEndClientBuild)
            {

                return AddField(pName, pType, null, pCount, pStartClientBuild, pEndClientBuild, null);
            }

            public Field AddField(string pName, Type pType, string pValue, int pCount, int pStartClientBuild, int pEndClientBuild)
            {

                return AddField(pName, pType, pValue, pCount, pStartClientBuild, pEndClientBuild, null);
            }

            public Field AddField(string pName, Type pType, int pCount, int pStartClientBuild, int pEndClientBuild, string pDescription)
            {

                return AddField(pName, pType, null, pCount, pStartClientBuild, pEndClientBuild, pDescription);
            }

            public Field AddField(string pName, Type pType, string pValue, int pCount, int pStartClientBuild, int pEndClientBuild, string pDescription)
            {
                Field tField = new Field() { Name = pName, Type = pType, Value = pValue, Count = pCount, StartClientBuild = pStartClientBuild, EndClientBuild = pEndClientBuild, Description = pDescription };
                tField.Index = Count + 1;
                Add(tField);

                return tField;
            }

        }

        public Field AddField(string pName, Type pType, int pCount, int pStartClientBuild, int pEndClientBuild)
        {

            return AddField(pName, pType, null, pCount, pStartClientBuild, pEndClientBuild, null);
        }

        public Field AddField(string pName, Type pType, string pValue, int pCount, int pStartClientBuild, int pEndClientBuild)
        {

            return AddField(pName, pType, pValue, pCount, pStartClientBuild, pEndClientBuild, null);
        }

        public Field AddField(string pName, Type pType, int pCount, int pStartClientBuild, int pEndClientBuild, string pDescription)
        {

            return AddField(pName, pType, null, pCount, pStartClientBuild, pEndClientBuild, pDescription);
        }

        public Field AddField(string pName, Type pType, string pValue, int pCount, int pStartClientBuild, int pEndClientBuild, string pDescription)
        {
            Field tField = new Field() { Name = pName, Type = pType, Value = pValue, Count = pCount, StartClientBuild = pStartClientBuild, EndClientBuild = pEndClientBuild, Description = pDescription };
            tField.Index = Fields.Count + 1;
            Fields.Add(tField);

            return tField;
        }



    }
}
